﻿<%@ Register TagPrefix="uc1" TagName="PageNavigation" Src="../UserControls/PageNavigation.ascx" %>

<%@ Page Language="c#" CodeBehind="AdvancedSearch.aspx.cs" AutoEventWireup="false"
    Inherits="BEGDC.CC.Web.Workflow.AdvancedSearch" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>SearchChange</title>
    <link href="../css/global.css" rel="stylesheet" type="text/css" />
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
    <link href="../css/content/entity.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script src="../js/jquery-ui.min.js" type="text/javascript"></script>

    <script src="../js/entity.js.aspx" type="text/javascript"></script>

    <script src="../js/common.js" type="text/javascript"></script>

    <script type="text/javascript">


        function showView(url) {
            window.open(url, null, 'height=760px,width=1106px,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes');
            event.returnValue = false;
        }
        function showSaveForm() {
            var code = window.showModalDialog('SaveAdvancedSearch.aspx', '', 'dialogHeight:300px;dialogWidth:400px;dialogTop:px;dialogLeft:px;center:Yes;scroll:yes;resizable:no;status:no;');
            //window.Form1.txtOperation.value = code;
            //window.parent.leftFrame.location.reload();
            if (typeof (code) == "undefined")
                return;
            if (code != "") {
                top.sidebarFrame.location.reload();
                //window.parent.leftFrame.location = '../left.aspx?item=1';
            }

        }

        function checkbadwords(textcontrol) {
            var badwords = "-%*'\"&()<>\\";
            if (!check(textcontrol.value, badwords)) {
                alert("Input invalid character(-%*'\"&()<>\\).");
                textcontrol.focus();
            }
        }


        function check(str, badwords) {
            if (typeof (str) != "string" || typeof (badwords) != "string") {
                return (false);
            }
            for (i = 0; i < badwords.length; i++) {
                bad = badwords.charAt(i);
                for (j = 0; j < str.length; j++) {
                    if (bad == str.charAt(j)) {
                        return false;
                        break;
                    }
                }
            }
            return true;
        }
    </script>

</head>
<body>
    <form id="Form1" method="post" runat="server">
    <div class="mainbox">
        <div class="sitemapbox">
            <div id="info" class="sitemap">
                &nbsp;»&nbsp;Search&nbsp;»&nbsp;Advanced Search
            </div>
        </div>
        <table cellspacing="0" cellpadding="0">
            <tr>
                <td>
                    <!--tab区域-->
                    <div class="tabbox purplebg_dark">
                        <ul class="tabpos">
                            <li><span class="tab_active">
                                <%=Resources.PageTitles.AdvancedSearch%></span></li>
                        </ul>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="formbox padding_lft5">
                        <span class="float_lft">
                            <asp:ResourceButton ID="btnSearch" runat="server" Text="Search" ToolTip="SearchTips"
                                CssClass="btn" />
                            <asp:ResourceButton ID="btnExport" runat="server" Text="Export" ToolTip="ExportTips"
                                CssClass="btn" />
                            <asp:ResourceButton ID="btnSaveSearch" runat="server" Text="SaveSearch" ToolTip="SaveSearchTips"
                                CssClass="btn" Style="display: none" />
                        </span>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="OCRDiv" runat="server" visible="false" class="formbox5 padding_lft5">
                        <span class="float_lft">
                            <asp:RadioButtonList ID="OCRRadioButtonList" runat="server" RepeatDirection="Horizontal"
                                Width="200">
                                <asp:ListItem Selected="True">IBGCR</asp:ListItem>
                                <asp:ListItem>EBD</asp:ListItem>
                                <asp:ListItem>ESC</asp:ListItem>
                                <asp:ListItem>ALL</asp:ListItem>
                            </asp:RadioButtonList>
                        </span>
                    </div>
                    <div id="OCVDiv" runat="server" visible="false" class="formbox5 padding_lft5">
                        <span class="float_lft">
                            <asp:RadioButtonList ID="OCVRadioButtonList" runat="server" RepeatDirection="Horizontal"
                                Width="200">
                                <asp:ListItem Selected="True">IBGCV</asp:ListItem>
                                <asp:ListItem>EBDCV</asp:ListItem>
                                <asp:ListItem>ESCCV</asp:ListItem>
                                <asp:ListItem>ALL</asp:ListItem>
                            </asp:RadioButtonList>
                        </span>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <!-- Search Setting -->
                    <div class="formbox1 padding_lft5" id="tblSetting">
                        <span class="float_lft">
                            <table id="tblSimpleSetting2" cellspacing="0" cellpadding="0" runat="server">
                                <tr>
                                    <td>
                                        <asp:DropDownList ID="ddlColumn1" runat="server" onchange="javascript:show_status(1, this.value);"
                                            CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:DropDownList ID="ddlOperator1" runat="server" CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:TextBox ID="txtValue1" onmouseover="this.className='TEXTBOXHOVER';" onmouseout="this.className='TEXTBOX';"
                                            runat="server" onblur="javascript:checkbadwords(this)" MaxLength="30"></asp:TextBox>
                                        <asp:TextBox ID="txtTime1" class="datepicker" runat="server" MaxLength="30"></asp:TextBox>
                                        <%--<img id="dtImg1" onclick="showCalendar('Form1','txtValue1','dtImg1',false,1,1,1950,31,12,2100);return false;"
                                        src="../images/calendar.gif" alt="calendar" name="dtImg1" runat="server">--%>
                                        <asp:DropDownList ID="ddlStatus1" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlProvince1" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCategory1" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCluster1" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlExecutive1" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:DropDownList ID="ddlLogic1" runat="server" onchange="javascript:show_condition(1, this.value);"
                                            CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr id="condition_tr2">
                                    <td class="padding_top5 padding_btm5">
                                        <asp:DropDownList ID="ddlColumn2" runat="server" onchange="javascript:show_status(2, this.value);"
                                            CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:DropDownList ID="ddlOperator2" runat="server" CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:TextBox ID="txtValue2" onmouseover="this.className='TEXTBOXHOVER';" onmouseout="this.className='TEXTBOX';"
                                            runat="server" onblur="javascript:checkbadwords(this)" MaxLength="30"></asp:TextBox>
                                        <asp:TextBox ID="txtTime2" class="datepicker" runat="server" MaxLength="30"></asp:TextBox>
                                        <%--<img id="dtImg2" onclick="showCalendar('Form1','txtValue2','dtImg2',false,1,1,1950,31,12,2100);return false;"
                                        src="../images/calendar.gif" alt="calendar" name="dtImg2" runat="server" />--%>
                                        <asp:DropDownList ID="ddlStatus2" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlProvince2" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCategory2" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCluster2" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlExecutive2" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:DropDownList ID="ddlLogic2" runat="server" onchange="javascript:show_condition(2, this.value);"
                                            CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr id="condition_tr3">
                                    <td>
                                        <asp:DropDownList ID="ddlColumn3" runat="server" onchange="javascript:show_status(3, this.value);"
                                            CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:DropDownList ID="ddlOperator3" runat="server" CssClass="formfont">
                                        </asp:DropDownList>
                                    </td>
                                    <td class="padding_lft5">
                                        <asp:TextBox ID="txtValue3" onmouseover="this.className='TEXTBOXHOVER';" onmouseout="this.className='TEXTBOX';"
                                            runat="server" onblur="javascript:checkbadwords(this)" MaxLength="30"></asp:TextBox>
                                        <asp:TextBox ID="txtTime3" class="datepicker" runat="server" MaxLength="30"></asp:TextBox>
                                        <%--<img id="dtImg3" onclick="showCalendar('Form1','txtValue3','dtImg3',false,1,1,1950,31,12,2100);return false;"
                                        src="../images/calendar.gif" alt="calendar" name="dtImg3" runat="server" />--%>
                                        <asp:DropDownList ID="ddlStatus3" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlProvince3" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCategory3" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlCluster3" runat="server">
                                        </asp:DropDownList>
                                        <asp:DropDownList ID="ddlExecutive3" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </table>
                        </span>
                    </div>
                    <div class="formbox padding_lft5">
                        <span id="lnkToggleFields" onclick="ShowFields();" style="cursor: hand">&gt;&gt;Show
                            display options (显示选项) </span>
                        <asp:TextBox ID="txtDisplayFields" runat="server" Style="display: none"></asp:TextBox>
                    </div>
                    <div class="formbox5 padding_lft5">
                        <table class="padding5" id="tblChooseFields" cellspacing="0" cellpadding="0">
                            <tr align="center">
                                <td>
                                    <asp:Label ID="lbGroup" runat="server"><h3><span>Selected (选定)</span></h3></asp:Label>
                                </td>
                                <td width="40">
                                </td>
                                <td>
                                    <asp:Label ID="lbNoGroup" runat="server"><h3><span>Unselected (未选定)</span></h3></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:ListBox ID="TargetBox" runat="server" DataTextField="GroupName" DataValueField="GroupID"
                                        SelectionMode="Multiple" Height="180px" CssClass="padding_lft5 formfont width240">
                                    </asp:ListBox>
                                </td>
                                <td align="center" width="40">
                                    <asp:ImageButton ID="btnRemove" runat="server" ImageUrl="../Images/Icon_Arrow-R.gif">
                                    </asp:ImageButton>
                                    <img src="../Images/ed_blank.gif" alt="ed_blank" />
                                    <asp:ImageButton ID="btnRemoveAll" runat="server" ImageUrl="../Images/Icon_Arrow-RR.gif">
                                    </asp:ImageButton>
                                    <img src="../Images/ed_blank.gif" alt="ed_blank" />
                                    <asp:ImageButton ID="btnAdd" runat="server" ImageUrl="../Images/Icon_Arrow-L.gif">
                                    </asp:ImageButton>
                                    <img src="../Images/ed_blank.gif" alt="ed_blank" />
                                    <asp:ImageButton ID="btnAddAll" runat="server" ImageUrl="../Images/Icon_Arrow-LL.gif">
                                    </asp:ImageButton>
                                </td>
                                <td>
                                    <asp:ListBox ID="SourceBox" runat="server" DataTextField="GroupName" DataValueField="GroupID"
                                        SelectionMode="Multiple" Height="180px" CssClass="padding_lft5 formfont width240">
                                    </asp:ListBox>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!-- Search Result -->
                    <table id="tblResult" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <asp:Panel ID="Panel1" Visible="False" runat="server">
                                    <div id="divGrid">
                                        <asp:DataGrid ID="dgTaskList" runat="server" EnableViewState="true" AllowSorting="True"
                                            PagerStyle-Visible="False" AllowPaging="True" GridLines="both" AutoGenerateColumns="False"
                                            ShowHeader="True" CssClass="tablestyle">
                                            <%--<FooterStyle />--%>
                                            <ItemStyle CssClass="tbody"></ItemStyle>
                                            <HeaderStyle CssClass="thead"></HeaderStyle>
                                            <Columns>
                                                <asp:TemplateColumn HeaderText="Action <br/> 操作">
                                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                                    <ItemTemplate>
                                                        <asp:ImageButton ImageUrl="../Images/COMEDIT.GIF" ID="imageAdvancedSearch" CommandName="SetAdvancedSearch"
                                                            ToolTip="Open (打开)" runat="server"></asp:ImageButton>
                                                    </ItemTemplate>
                                                </asp:TemplateColumn>
                                            </Columns>
                                        </asp:DataGrid>
                                    </div>
                                    <table id="Table3" cellspacing="0" cellpadding="0" class="pagecounting">
                                        <tbody>
                                            <tr>
                                                <td>
                                                    Total Records:
                                                    <asp:Label ID="lblRecordCount" runat="server">lblRecordCount</asp:Label>
                                                    &nbsp;&nbsp;&nbsp;
                                                    <img src="../images/PageIcon.GIF" alt="PageIcon" />&nbsp;Page:
                                                    <asp:Label ID="lblCurrentPageIndex" runat="server">lblCurrentPageIndex</asp:Label>
                                                    &nbsp;/&nbsp;
                                                    <asp:Label ID="lblPageCount" runat="server">lblPageCount</asp:Label>
                                                </td>
                                                <td align="right">
                                                    <asp:ImageButton ID="btnPageFirst" runat="server" ImageUrl="../images/pg_first.gif"
                                                        ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                                                    <asp:ImageButton ID="btnPagePrev" runat="server" ImageUrl="../images/pg_pre.gif"
                                                        ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                                                    <asp:ImageButton ID="btnPageNext" runat="server" ImageUrl="../images/pg_next.gif"
                                                        ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                                                    <asp:ImageButton ID="btnPageLast" runat="server" ImageUrl="../images/pg_last.gif"
                                                        ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp; Go To Page:
                                                    <asp:TextBox ID="txtPage" runat="server" CssClass="txtbox pager-text" MaxLength="5"></asp:TextBox>
                                                    <asp:ImageButton ID="btnGotoPage" runat="server" ImageUrl="../images/PageIcon.GIF">
                                                    </asp:ImageButton>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <asp:Panel ID="Panel2" runat="server">
                                        <asp:Label ID="lblCostSum" runat="server"></asp:Label>
                                    </asp:Panel>
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <iframe id="frm" style="display: none"></iframe>
                </td>
            </tr>
        </table>
    </div>
    </form>

    <script language="javascript" type="text/javascript">
        check_control_visible();
        check_status_visible();
        check_displayfields_visible();

        $(function() {
            $(".datepicker").datepicker({
                showOn: "button",
                buttonImage: "../images/calendar.gif",
                buttonImageOnly: true,
                buttonText: 'Open Calendar (打开日历)'
            }).bind("keydown", function() { return false; });

            $(".datepicker:hidden").next().hide();
            //                        hideDatepicker(1);
            //                        hideDatepicker(2);
            //                        hideDatepicker(3);
        });

        //        function removeDatepicker(index) {
        //            $("#txtValue" + index)
        //            .removeAttr("readonly")
        //            .val('')
        //            .unbind()
        //            .blur(function() {
        //                var badwords = "-%*'\"&()<>\\";
        //                if (!check($(this).val(), badwords)) {
        //                    alert("Input invalid character(-%*'\"&()<>\\).");
        //                    $(this).focus();
        //                }
        //            })
        //            .hover(function() {
        //                $(this).removeClass('TEXTBOX');
        //                $(this).addClass('TEXTBOXHOVER');
        //            }, function() {
        //                $(this).removeClass('TEXTBOXHOVER');
        //                $(this).addClass('TEXTBOX');
        //             });
        //            var cl = $("#txtValue" + index).next().attr("class");
        //            if (cl != null && cl == 'ui-datepicker-trigger')
        //                $("#txtValue" + index).next().remove();
        //        }

        //

        function hideDatepicker(index) {
            $("#txtTime" + index).hide();
            $("#txtTime" + index).next(".ui-datepicker-trigger").hide();
        }
        function showDatepicker(index) {
            $("#txtTime" + index).show();
            $("#txtTime" + index).next(".ui-datepicker-trigger").show();
        }


        function show_condition(index, selectValue) {
            var ddl;

            if (selectValue == '') {
                if (index == 1) {
                    document.getElementById('condition_tr2').style.display = "none";
                    document.getElementById('condition_tr3').style.display = "none";
                    document.getElementById('ddlLogic2').options(0).selected = true;
                }
                else if (index == 2)
                    document.getElementById('condition_tr3').style.display = "none";
            }
            else {
                if (index == 1) {
                    document.getElementById('condition_tr2').style.display = "block";
                }
                else if (index == 2)
                    document.getElementById('condition_tr3').style.display = "block";
            }
        }
        function check_control_visible() {
            if (document.getElementById('ddlLogic1') == null) return;
            show_condition(1, document.getElementById('ddlLogic1').value);
            show_condition(2, document.getElementById('ddlLogic2').value);
        }
        function show_status(index, selectValue) {

            if (selectValue == "Cluster" || selectValue == "CAT" || selectValue == "CompanyExecutive" || selectValue == "Bransh") {
                document.getElementById("ddlStatus" + index).style.display = "none";
                document.getElementById("txtValue" + index).style.display = "none";
                hideDatepicker(index);
                document.getElementById("ddlOperator" + index).setAttribute("value", "=");
                document.getElementById("ddlOperator" + index).setAttribute("disabled", "true");
                document.getElementById("txtValue" + index).readOnly = false;
                //document.getElementById("dtImg" + index).style.display = "none";

                if (selectValue == "Bransh") {
                    document.getElementById("ddlCategory" + index).style.display = "none";
                    document.getElementById("ddlCluster" + index).style.display = "none";
                    document.getElementById("ddlExecutive" + index).style.display = "none";
                    document.getElementById("ddlProvince" + index).style.display = "";
                }
                if (selectValue == "Cluster") {
                    document.getElementById("ddlCategory" + index).style.display = "none";
                    document.getElementById("ddlProvince" + index).style.display = "none";
                    document.getElementById("ddlExecutive" + index).style.display = "none";
                    document.getElementById("ddlCluster" + index).style.display = "";
                }
                if (selectValue == "CAT") {
                    document.getElementById("ddlProvince" + index).style.display = "none";
                    document.getElementById("ddlCluster" + index).style.display = "none";
                    document.getElementById("ddlExecutive" + index).style.display = "none";
                    document.getElementById("ddlCategory" + index).style.display = "";
                }
                if (selectValue == "CompanyExecutive") {
                    document.getElementById("ddlCategory" + index).style.display = "none";
                    document.getElementById("ddlCluster" + index).style.display = "none";
                    document.getElementById("ddlProvince" + index).style.display = "none";
                    document.getElementById("ddlExecutive" + index).style.display = "";
                }
            }
            else {
                document.getElementById("ddlCategory" + index).style.display = "none";
                document.getElementById("ddlCluster" + index).style.display = "none";
                document.getElementById("ddlProvince" + index).style.display = "none";
                document.getElementById("ddlExecutive" + index).style.display = "none";
                if (selectValue == "Status") {
                    document.getElementById("ddlStatus" + index).style.display = "";
                    document.getElementById("txtValue" + index).style.display = "none";
                    hideDatepicker(index);
                    document.getElementById("ddlOperator" + index).setAttribute("value", "=");
                    document.getElementById("ddlOperator" + index).setAttribute("disabled", "true");
                    //document.getElementById("txtValue" + index).readOnly = false;
                    //document.getElementById("dtImg" + index).style.display = "none";
                }
                else {
                    document.getElementById("ddlStatus" + index).style.display = "none";
                    //document.getElementById("txtValue" + index).style.display = "";
                    document.getElementById("ddlOperator" + index).removeAttribute("disabled");

                    if (selectValue.indexOf("Date") > -1) {
                        //document.getElementById("txtValue" + index).readOnly = true;
                        //document.getElementById("dtImg" + index).style.display = "";
                        document.getElementById("txtValue" + index).style.display = "none";
                        showDatepicker(index);
                    }
                    else {
                        //document.getElementById("txtValue" + index).readOnly = false;
                        //document.getElementById("dtImg" + index).style.display = "none";
                        document.getElementById("txtValue" + index).style.display = "";
                        hideDatepicker(index);
                    }
                }
            }
        }
        function check_status_visible() {
            if (document.getElementById('ddlLogic1') == null) return;
            show_status(1, document.getElementById('ddlColumn1').value);
            show_status(2, document.getElementById('ddlColumn2').value);
            show_status(3, document.getElementById('ddlColumn3').value);
        }

        function check_displayfields_visible() {
            //           document.getElementById("tblChooseFields").style.display = "none";
            if (document.getElementById("txtDisplayFields").value == "Show") {
                document.getElementById("tblChooseFields").style.display = "";
                document.getElementById("lnkToggleFields").innerText = "-Hide display options (隐藏选项)";
            }
            else {
                document.getElementById("tblChooseFields").style.display = "none";
            }
        }
        function ResetForm() {
            window.location.href = window.location.href;
        }
        function DoAction(action) {


        }
        function OnSelectColumn() {

        }

        function ShowFields() {
            if (document.getElementById("tblChooseFields").style.display == "") {
                document.getElementById("tblChooseFields").style.display = "none";
                document.getElementById("lnkToggleFields").innerText = "+Show display options (显示选项)";
                document.getElementById("txtDisplayFields").value = "Hide"
            }
            else {
                document.getElementById("tblChooseFields").style.display = "";
                document.getElementById("lnkToggleFields").innerText = "-Hide display options (隐藏选项)";
                document.getElementById("txtDisplayFields").value = "Show"
            }
        }
    </script>

    <%--页面刷新时显示--%>
    <%--<div id="dialog-message" title="Loading..." style="display: none">
        <p>
            <br />
            <span class="entity-loading"></span><span>Operation in process, please wait...<br />
                <br />
                处理中, 请稍候。。。</span>
        </p>
    </div>--%>
</body>
</html>
